<?php
require_once('lib/dbclass.php');
$db = new MySQL();



if (! $db->Query("select * from berita
	order by id_berita desc")) $db->Kill(); 

?>

<h2>Admin Berita</h2>
<div class="tabeledit">
<table border="0" width="100%">
	<tr>
	<th align="center" width="8%" bgcolor="#494949"><p>No</p></th>
	<th align="left" width="10%" bgcolor="#494949"><p>Kode</p></th>
	<th align="left" width="20%" bgcolor="#494949"><p>Judul</p></th>
	<th align="left" width="20%" bgcolor="#494949"><p>Isi</p></th>
	<th align="left" width="17%" bgcolor="#494949"><p>Tanggal</p></th>
	<th align="left" width="22%" bgcolor="#494949"><p>Aksi</p></th>
	</tr>
	<?php $no=1;?>
	<?php while($rs = $db->RowArray()):?>
	<tr>
	<td><?php echo $no?></td>
	<td><?php echo $rs['id_berita']?></td>
	<td><?php echo $rs['judul']?></td>
	<td><?php echo $rs['isi_berita']?></td>
	<td><?php echo $rs['tanggal']?></td>
	<td><a class="btn btn-default btn-sm" href="index.php?q=16&id=<?php echo $rs['id_berita'];?>"><i class="fa fa-cog"></i> Settings</a>
		<a class="btn btn-danger" href="hapus_berita.php?id=<?php echo $rs['id_berita'];?>" onclick="return cekHapus('<?php 
		echo $rs['judul'];?>');"><i class="fa fa-trash-o"></i> Delete</a>
        
        </td>
	</tr>
	<tr>
	  <td colspan="5"><hr></td>
  </tr>
	<?php $no++?>
	<?php endwhile;?>
</table>
</div><br/><br/><br/><br/>
<a href="?q=15" class="btn btn-danger">
	Tambah Berita
</a> 
<script language="JavaScript">
function cekHapus(nama){
	if(confirm("Yakin akan menghapus berita : \""+ nama +" ? \"")){
		return true;
	} else {
		return false;
	}
}
</script>
